﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TpBaseObjects.Models;
using TpData.Layer;

namespace TpData.Manager {
    
    public class TpAccountingDataManager {

        #region Members
        #endregion

        #region Load

        public static string GetAccountName(string accountNo, string company) {
            using (TpAccountingDataLayer dl = CreateTpAccountingDataLayer()) {
                return dl.GetAccountName(accountNo, company);
            }
        }

        public static List<CashSaleProductsModel> LoadProducts() {
            using (TpAccountingDataLayer dl = CreateTpAccountingDataLayer()) {
                return dl.LoadProducts();
            }
        }

        public static List<TaxesModel> LoadTaxes() {
            using (TpAccountingDataLayer dl = CreateTpAccountingDataLayer()) {
                return dl.LoadTaxes();
            }
        }

        #endregion
        
        #region Save

        public static int SaveAccount(int accountID, int accountNumber, string accountName, string description = null, string details = null, string text = null, bool sk = false) {
            using (TpAccountingDataLayer dl = CreateTpAccountingDataLayer()) {
                return dl.SaveAccount(accountID, accountNumber, accountName, description, details, text, sk);
            }
        }

        public static int SaveAccount2Company(int accountID, int orgKey) {
            using (TpAccountingDataLayer dl = CreateTpAccountingDataLayer()) {
                return dl.SaveAccount2Company(accountID, orgKey);
            }
        }

        #endregion
        
        #region Update

        public static void UpdateAccount2Company(int accountID, int orgKey) {
            using (TpAccountingDataLayer dl = CreateTpAccountingDataLayer()) {
                dl.UpdateAccount2Company(accountID, orgKey);
            }
        }

        #endregion

        #region Functions

        private static TpAccountingDataLayer CreateTpAccountingDataLayer() {
            return (DataManager.CreateDataLayer(typeof(TpAccountingDataLayer)) as TpAccountingDataLayer);
        }

        #endregion

    }
}
